package linwen.wang.timer;

import lombok.extern.slf4j.Slf4j;

import java.util.Date;
import java.util.TimerTask;

@Slf4j
public class TestTimerTask extends TimerTask {
    private String name;
    private static int count = 0;

    public TestTimerTask(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        count++;
        log.info("current loop:{}",count);
        log.info(Thread.currentThread().getName()+"=="+name+"  start"+new Date());
        try {
            if(count==10){
                Thread.sleep(5000);
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        log.info(Thread.currentThread().getName()+"=="+name+"  end"+new Date());
    }
}
